<!DOCTYPE html >
<html>
<head>
    <meta name="Generator" content="TPshop v1.1" />
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <title>首页-{$tpshop_config['shop_info_store_title']}</title>
    <meta http-equiv="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
    <meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/public.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/index.css"/>

    <script type="text/javascript" src="__STATIC__/js/jquery-1.10.1.min.js"></script>
    <script src="__STATIC__/js/jweixin-1.0.0.js"></script>

    <script>
        wx.config({
            debug: true,
            appId: "{$signPackage[appId]}",
            timestamp:"{$signPackage[timestamp]}",
            nonceStr:"{$signPackage[nonceStr]}",
            signature:"{$signPackage[signature]}",
            jsApiList:[
                // 'getLocation',
                'scanQRCode',
            ]
        });

        wx.ready(function () {

            wx.getLocation({
                success: function (res) {
                    var latitude = res.latitude; //纬度
                    var longitude = res.longitude; //经度
                    var sylat = '22.510816';//商友纬度
                    var sylon = '113.398849';//商友经度

                    var milljl = getDisance(latitude,longitude,sylat,sylon);
                    if(milljl<100){
                        $('#juli').val(milljl);
                        $('#btn1').show();
                    }


//                    alert(milljl);return false;
                },
                cancel: function (res) {
                    alert('用户拒绝授权获取地理位置');
                },
                fail: function (res) {
                    alert(JSON.stringify(res));
                }
            });


            $("#btnscan").click(function() {
                //  alert(111111);
                wx.scanQRCode({
                    // 默认为0，扫描结果由微信处理，1则直接返回扫描结果
                    needResult : 1,
                    desc : 'scanQRCode desc',
                    success : function(res) {
                        // alert(2222);
                        //扫码后获取结果参数赋值给Input
                        var url = res.resultStr;
                        //商品条形码，取","后面的
                        if(url.indexOf(",")>=0){
                            var tempArray = url.split(',');
                            var tempNum = tempArray[1];
                            $("#id_securityCode_input").val(tempNum);
                        }
                        else if(url.indexOf("http")>=0){
                            //跳转
                            $("#id_securityCode_input").val(url);
                        }else{
                            $("#id_securityCode_input").val(url);
                        }
                    }
                });
            });
        });

    </script>




    <script>
        function getDisance(lat1, lng1, lat2, lng2) {
            var radLat1 = lat1 * Math.PI / 180.0;
            var radLat2 = lat2 * Math.PI / 180.0;
            var a = radLat1 - radLat2;
            var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
            var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
            s = s * 6378.137;
            s = Math.round(s * 10000) / 10000;
            return s*100
        };

        function sub_form1(){
            $('#form1').submit();
        }
    </script>
</head>
<body>



<!--<a href="" class="i_user_pic">头像</a>-->
<img src="{$user.head_pic}">

<div class="text">当前在线：86 人</div>
<form action="{:U('Mobile/index/open_test')}" method="post" id="form1" >
    <!--<input name="user_id" id="user_id" value="{$user.user_id}">-->
    <input id="juli" type="text" name="juli" />
    <input id="id_securityCode_input" type="text" name="wx_code" />
    <!--<button id="btn1"  >扫码</button>-->

    <!--<br><br>坐标：<div id="locationText"></div>-->
    <!--<a href="{:U('Mobile/index/open_test')}" class="open_men">开门 | 结算</a>-->
    <a href="#" id="btnscan"  class="open_men" >开门 | 结算</a>

</form>

<div class="text">公告：恒力春节放假通知，本馆由2月13日农历…</div>

<include file="Public/footer_nav"/>

</body>
</html>